package com.opencvjava.lessons.imgproc;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;
import org.springframework.stereotype.Service;

import static com.opencvjava.support.util.CvUtils.imshow;
import static com.opencvjava.support.util.CvUtils.mat;
import static org.opencv.core.Core.inRange;
import static org.opencv.imgproc.Imgproc.cvtColor;

@Service
public class L9_ThresholdingUsingInRange {
    public void test() {
        Mat frame = mat("lena.jpg");
        Mat frameHSV = new Mat();
        cvtColor(frame, frameHSV, Imgproc.COLOR_BGR2HSV);
        Mat thresh = new Mat();
        inRange(frameHSV, Scalar.all(50),
                Scalar.all(255), thresh);
        imshow("原图", frame);
        imshow("结果", thresh);
    }
}
